/*
* Copyright (c) 2016 . All Rights Reserved.
*/
package com.cgmnx.admin.common.util;

import com.cgmnx.admin.common.constants.WebConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;

/**
 * @author: created  Date: 16/12/21 Time: 下午1:19
 * @version: 1.0
 */
@Slf4j
public final class DateUtil {

    public static String formatDatetime(Date createTime) {

        if (createTime == null) {
            return StringUtils.EMPTY;
        }

        try {
            return DateFormatUtils.format(createTime, WebConstant.ISO_DATETIME_TIME_ZONE_FORMAT);
        } catch (Exception e) {
            log.error("格式化时间错误,时间为:{}", e);
            return StringUtils.EMPTY;
        }

    }
}